package com.cskaoyan.utils;

/**
 * @author wenkaikai
 * @since 2022/08/14 20:50
 */
public class TypeConverter {

    /**
     * string 转  int数组
     *
     * @param str
     * @return
     */
    public static Integer[] stringToIntegerArray(String str) {
        if (str == null || "".equals(str)) {
            return null;
        }
        if (str.equals("[]")) {
            return new Integer[0];
        }
        String substring = str.substring(1, str.length() - 1);
        String[] split = substring.split(",");
        Integer[] integers = new Integer[split.length];
        int i = 0;
        for (String s : split) {
            integers[i++] = Integer.parseInt(s);
        }
        return integers;
    }
}